package com.cyan.app.workflow.service;

import android.app.Notification;
import android.app.Service;
import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.IBinder;

import com.cyan.app.workflow.AppContext;

/**
 * Created by GivenTang on 2015/7/28.
 */
public class MainService extends Service {
    private static final String TAG = "MainService";

    private Context mContext;

    @Override
    public IBinder onBind(Intent intent) {
        return null;
    }

    @Override
    public void onCreate() {
        super.onCreate();

        Notification notifyForeground = new Notification();
        if (Build.VERSION.SDK_INT < 18) {
            startForeground(100, notifyForeground);
        }

        mContext = AppContext.getInstance();
    }

    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, Service.START_STICKY, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    public static void start(Context context) {
        context.startService(new Intent(context, MainService.class));
    }

    public static void stop(Context context) {
        context.stopService(new Intent(context, MainService.class));
    }

}
